// 附件接口
export interface MessageAttachment {
  id: number | string;
  type: 'file' | 'image' | 'audio' | 'video' | 'link' | 'question';
  name: string;
  url?: string;
  size?: number;
  duration?: number;
  thumbnail?: string;
  title?: string;
  description?: string;
}

// 聊天消息
export class ChatMessage {
  id?: number;
  role: 'user' | 'assistant';
  content: string;
  type?: 'text' | 'code' | 'markdown';
  timestamp: number;
  attachments?: MessageAttachment[];

  constructor(options: Omit<ChatMessage, 'timestamp'> & { timestamp?: number }) {
    this.id = options.id;
    this.role = options.role;
    this.content = options.content;
    this.type = options.type;
    this.timestamp = options.timestamp || Date.now();
    this.attachments = options.attachments || [];
  }
}

// 分页信息接口
export interface PaginationInfo {
  currentPage: number;
  pageSize: number;
  total: number;
  hasMore: boolean;
}

// 对话信息
export class IChatInfo {
  id: number;
  title: string;
  created_at?: Date;
  messages?: ChatMessage[];
  pagination?: PaginationInfo;

  constructor(id: number, title: string, created_at: Date, messages: ChatMessage[] = []) {
    this.id = id;
    this.title = title;
    this.created_at = created_at;
    this.messages = messages;
    this.pagination = {
      currentPage: 1,
      pageSize: 10,
      total: 0,
      hasMore: false,
    };
  }
}

export interface IStreamChatParams {
  content: string;
  conversation_id: string | number;
  params?: Record<string, any>;
}
